package com.msgserver.mbeans;


import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

import org.primefaces.event.TabChangeEvent;

import com.msgserver.entity.Company;
import com.msgserver.entity.CompanyAdmin;


@javax.faces.bean.ManagedBean
@SessionScoped
public class GlobalBean {

	private CompanyAdmin admin;


	public CompanyAdmin getAdmin() {
		return admin;
	}

	public void setAdmin(CompanyAdmin admin) {
		this.admin = admin;
	}
	
	public void tabChange(TabChangeEvent event){
		String activeTab = event.getTab().getId();
		if(activeTab.equals("msgSenderTab")){
			FacesContext facesContext = FacesContext.getCurrentInstance();
			MsgSenderBean msgSenderBean = (MsgSenderBean) facesContext.getApplication().getVariableResolver().resolveVariable(facesContext,"msgSenderBean");
			MsgAdminBean msgAdminBean = (MsgAdminBean) facesContext.getApplication().getVariableResolver().resolveVariable(facesContext,"msgAdminBean");
			msgSenderBean.setCompany(msgAdminBean.getCompany());
			msgSenderBean.init();
		}
		
	}
	
	
	
}
